﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="Listr.aspx.cs" Inherits="cebao.Web.ForestPets.Listr" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
     <link href="../CSS/IconExtension.css" rel="stylesheet" />
    <script src="../Script/export.js"></script>
    <script src="../Script/username.js"></script>
    <script src="../Script/datetime.js"></script> 
    <script src="../Script/highcharts.js"></script>  
    <script src="../Script/exporting.js"></script>
    <script type="text/javascript">
        var uid = 0;
        var phone = 0;
        var chs;
        var mpet = "";
        var mpetv = "";
        var griddata = "";
        var cadd = "";
        var  dtOpstart="" ;
        var dtOpend = "";
        var filterObj = "";
        var add="";
        var uname = "";
        var qxchs;
        var level = 0;
        Array.prototype.deleteElementByValue = function (varElement) {
            var numDeleteIndex = -1;
            for (var i = 0; i < this.length; i++) {
                // 严格比较，即类型与数值必须同时相等。
                if (this[i] === varElement) {
                    this.splice(i, 1);
                    numDeleteIndex = i;
                    break;
                }
            }
            return numDeleteIndex;
        }
        function getfids(rows) {
            var ids = "";
            for (var i = 0; i < rows.length; i++)
                ids = ids + rows[i].fp_id + ",";
            if (ids != "")
                ids = ids.substr(0, ids.length - 1);
            return ids;

        }
        function getids(rows) {
            var ids = "";
            for (var i = 0; i < rows.length; i++)
                ids = ids + rows[i].uid + ",";
            if (ids != "")
                ids = ids.substr(0, ids.length - 1);
            return ids;

        }
        function opend()
        {
            $('#suser').datagrid({
                title: '用户列表', //表格标题
                url: '../userinfo/GetUser.ashx', //请求数据的页面
                sortName: 'uname', //排序字段
                idField: 'uid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: false,
                method: 'post',
                columns: [[
                    { field: 'ckb', checkbox: true },
	                { title: '用户名', field: 'uname', width: 80, sortable: true },
                    { title: '地址', field: 'adds', width: 150 },                    
                    {
                        title: '用户权限等级', field: 'ulevel', width: 100, formatter: function (value, row, index) {
                            if (value == 0) {
                                return "普通用户";
                            } else if (value == 1) {
                                return "县级用户";
                            } else if (value == 2) {
                                return "市级用户";
                            } else if (value == 3) {
                                return "省级用户";
                            } else if (value == 4) {
                                return "全国用户";
                            } else if (value == 5) {
                                return "管理员";
                            } else if (value == -1) {
                                return "省级代理商";
                            }
                        }
                    }
                ]],                
                queryParams: { "action": "getparent","uid":uid },
                pagination: false, //是否开启分页                
                rownumbers: true //行号
            });
            $('#dlg').dialog('open').dialog('setTitle', '发送信息');
        }
        function sendmsg() {
            var rows = $('#suser').datagrid('getSelections');
            if (rows == null || rows.length == 0) {
                $.messager.alert("提示", "请选择要设置的行！", "info");
                return;
            }
            if (rows) {
                $.messager.confirm('提示', '你确定要发送吗？', function (r) {
                    if (r) {
                        var uids = getids(rows);
                        var msg = $('#yjfx').text();
                        var title = "预警提醒";
                        $('#fm').form('submit', {
                            url: "../info/getinfo.ashx?action=adds&title=" + title + "&uid=" + uids + "&infocontent=" + msg,
                            onSubmit: function () {
                                return $(this).form('validate');
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $('#dlg').dialog('open').dialog('close');
                                    $.messager.alert("提示", "恭喜您，信息发送成功", "info");
                                }
                                else if ((result.indexOf("F") == 0)) {
                                    $.messager.alert("提示", "发送失败，请重新操作！", "info");
                                    return;
                                }
                                else if ((result.indexOf("L") == 0)) {
                                    $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                                    top.location = '/index.aspx';
                                    return;
                                }
                            }
                        });

                    }
                })
            }           

        }
        $(function () {
            $.ajax({
                type: "post",
                dataType: "json",
                url: "../admin/getinfo.ashx?action=level",
                success: function aa(data) {
                    var level = data[0].level;
                    if (level != 5 && level != 1) {
                        $("#a_del").hide();
                    }
                }
            });
            year = new Date().getFullYear();
            $('#jd').combobox({
                onSelect: function (newValue, oldValue) {
                    if (newValue.text == '一季度') {
                        $("#StartTime").datebox("setValue", year + "-1-1");
                        $("#EndTime").datebox("setValue", year + "-3-31");
                    }
                    else if (newValue.text == '二季度') {
                        $("#StartTime").datebox("setValue", year + "-4-1");
                        $("#EndTime").datebox("setValue", year + "-6-30");
                    }
                    else if (newValue.text == '三季度') {
                        $("#StartTime").datebox("setValue", year + "-7-1");
                        $("#EndTime").datebox("setValue", year + "-9-30");
                    }
                    else if (newValue.text == '四季度') {
                        $("#StartTime").datebox("setValue", year + "-10-1");
                        $("#EndTime").datebox("setValue", year + "-12-31");
                    }
                    else if (newValue.text == '当天') {
                        var curr_time = new Date();
                        var tc_time = new Date(curr_time.getTime() + 24 * 60 * 60 * 1000);
                        var strDate = curr_time.getFullYear() + "-";
                        strDate += curr_time.getMonth() + 1 + "-";
                        strDate += curr_time.getDate();
                        var strDateend = tc_time.getFullYear() + "-";
                        strDateend += tc_time.getMonth() + 1 + "-";
                        strDateend += tc_time.getDate();
                        $("#StartTime").datebox("setValue", strDate);
                        $("#EndTime").datebox("setValue", strDateend);
                    }
                }
            });
            var curr_time = new Date();
            var tc_time = new Date(curr_time.getTime()+24*60*60*1000);
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";            
            strDate += curr_time.getDate();
            var strDateend = tc_time.getFullYear() + "-";
            strDateend += tc_time.getMonth() + 1 + "-";
            strDateend += tc_time.getDate();
            $("#StartTime").datebox("setValue", strDate);
            $("#EndTime").datebox("setValue", strDateend);
            uid = getUrlParam("uid");
            $.ajax({
                type: "post",
                dataType: "json",
                url: "../userinfo/getuser.ashx?action=getinfo&uid=" + uid,
                success: function aa(data) {
                    add = data[0].province + data[0].province + data[0].city + data[0].county;
                    name = data[0].name;                   
                    
                }
            });
            phone = getUrlParam("qh");
            $('#mypets').combobox({
                url: 'GetPets.ashx?action=mypet&uid='+uid,
                valueField: 'mhid',
                textField: 'hname',
                panelHeight: 'auto',
                editable: false,
                onLoadSuccess: function () {
                    if (cadd == "") {
                        var cdata = $('#mypets').combobox('getData');
                        cdata.unshift({ "hname": "全部", "mhid": "0" });
                        cadd = "a";
                        $("#mypets").combobox('loadData', cdata);
                    }
                    else {
                        $("#mypets").combobox('select', 0);
                    }
                }
            });
            $('#ptype').combobox({
                onSelect: function (newValue, oldValue) {
                    if (newValue.text != '成虫') {
                        colums = "[[{ field: 'ckb', checkbox: true },{ title: '区域', field: 'address', width: 150, sortable: true },{ title: '树种', field: 'pname', width: 80 }, { title: '虫名', field: 'hname', width: 150 }, { title: '虫态', field: 'petStage', width: 150 }, { title: '虫龄', field: 'larvaAge', width: 150 }, { title: '受害部位', field: 'damageParts', width: 150 }, { title: '统计单位', field: 'totalUnit', width: 150 }, { title: '统计数据', field: 'totalCount', width: 150 }, {     title: '发生程度', field: 'happenpro', width: 100 },{ title: '监测人', field: 'uname', width: 80 },{ title: '监测点', field: 'mname', width: 150 },{ title: '监测时间', field: 'inputTime', width: 150, formatter: function (value, row, index) {if (value != '') {if (value.indexOf('-') != -1) value = value.replace(/-/g, \"/\"); return new Date(value).pattern('yyyy年M月d日');}}}]]";

                        $('#tt').datagrid({ columns: eval(colums) });
                    }
                    else {
                        //雄虫数量	雌虫数量	性比	成虫总数
                        colums = "[[{ field: 'ckb', checkbox: true },{ title: '区域', field: 'address', width: 150, sortable: true }, { title: '虫名', field: 'hname', width: 150 }, { title: '雄虫数量', field: 'maleNums', width: 150 }, { title: '雌虫数量', field: 'femaleNums', width: 150 }, { title: '性比', field: 's', width: 150,formatter: function (value, row, index) { return (row.maleNums/row.femaleNums).toFixed(2);} }, { title: '成虫总数', field: 'totalUnit', width: 150,formatter: function (value, row, index) { return parseInt(row.maleNums)+parseInt(row.femaleNums);} }, { title: '监测人', field: 'uname', width: 80 },{ title: '监测点', field: 'mname', width: 150 },{ title: '监测时间', field: 'inputTime', width: 150, formatter: function (value, row, index) {if (value != '') {if (value.indexOf('-') != -1) value = value.replace(/-/g, \"/\"); return new Date(value).pattern('yyyy年M月d日');}}}]]";

                        $('#tt').datagrid({ columns: eval(colums) });

                    }
                }
            });
            InitGird();
           
        });
            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null) return unescape(r[2]); return null; //返回参数值
            }
            function InitGird() {
                $('#tt').datagrid({
                    title: '虫情动态_虫害', //表格标题
                    url: 'GetPets.ashx', //请求数据的页面
                    sortName: 'inputTime', //排序字段
                    idField: 'fp_id', //标识字段,主键
                    iconCls: '', //标题左边的图标
                    width: '100%', //宽度
                    nowrap: false, //是否换行，True 就会把数据显示在一行里
                    striped: true, //True 奇偶行使用不同背景色
                    collapsible: false, //可折叠
                    sortOrder: 'desc', //排序类型
                    remoteSort: true, //定义是否从服务器给数据排序
                    fitColumns: true,
                    singleSelect: false,
                    method: 'post',
                    columns: [[//
                        { field: 'ckb', checkbox: true },
                        { title: '区域', field: 'address', width: 150, sortable: true },
                        { title: '树种', field: 'pname', width: 150 },
                        { title: '虫名', field: 'hname', width: 150 },
                        { title: '虫态', field: 'petStage', width: 150 },
                        { title: '虫龄', field: 'larvaAge', width: 150 },
                        { title: '受害部位', field: 'damageParts', width: 150 },
                        { title: '统计单位', field: 'totalUnit', width: 150 },
                        { title: '统计数据', field: 'totalCount', width: 150 },
                        {
                            title: '发生程度', field: 'happenpro', width: 100
                        },
                        { title: '监测人', field: 'uname', width: 80 },
                        { title: '监测点', field: 'mname', width: 150 },
                        {
                            title: '监测时间', field: 'inputTime', width: 200, formatter: function (value, row, index) {
                                if (value != "") {

                                    if (value.indexOf("-") != -1)
                                        value = value.replace(/-/g, "/")
                                    return new Date(value).pattern("yyyy年M月d日");
                                }
                            }
                        }
                    ]
                    ],
                    rowStyler: function (index, row) {
                        var value = row.happenpro;
                        if (value == '轻度以下') {
                            return 'color:green; font-weight:bold;';
                        }
                        else if (value == '轻度') {
                            return 'color:blue; font-weight:bold;';
                        }
                        else if (value == '中度') {
                            return 'color:#FF00FF; font-weight:bold;';
                        }
                        else if (value == '重度') {
                            return 'color:red; font-weight:bold;';
                        }
                    },
                    toolbar: "#tab_toolbar",
                    queryParams: { "action": "query", "uid": uid, "StartTime": $("#StartTime").datebox("getValue"), "EndTime": $("#EndTime").datebox("getValue"), "ptype": $("#ptype").combobox("getValue") },
                    pagination: true, //是否开启分页
                    pageNumber: 1, //默认索引页
                    pageSize: 20, //默认一页数据条数
                    rownumbers: true ,
                    onLoadSuccess: function (data) {
                        griddata = data;                       
                            var max = 0;
                            var min = 0;
                            var sum = 0;
                            var pets = "";
                            var temp = 0;
                            var nums = 0;
                            var maxt = "";
                            var mint = "";
                            var sresult = "";
                            var snum = 0;
                            var result = "";
                            dtOpstart = $('#StartTime').datebox('getValue');
                            dtOpend = $('#EndTime').datebox('getValue');
                            $.each(data.rows, function (k, v) {                           
                                temp = v["hname"];
                                if (pets.indexOf(temp) == -1)
                                {
                                    pets = pets + temp + ",";
                                    nums = nums + 1;
                                }                            
                            });                        
                            var strs = new Array(); //定义一数组
                            if (pets.length > 0) pets = pets.substr(0, pets.length - 1);
                            strs = pets.split(","); //字符分割 
                            for (i = 0; i < strs.length ; i++) {
                                max = 0;
                                sum = 0;
                                maxt = "";
                                mint = "";
                                snum = 0;
                                sresult="";
                                if ($("#ptype").combobox('getValue') == "成虫") {
                                    if (data.rows.length > 0) min = parseInt(data.rows[0]["maleNums"]) + parseInt(data.rows[0]["femaleNums"]);
                                    $.each(data.rows, function (k, v) {
                                        if (v["hname"] == strs[i]) {
                                            temp = parseInt(v["maleNums"]) + parseInt(v["femaleNums"]);
                                            if (temp >= max) { max = temp; maxt = v["inputTime"]; }
                                            if (temp <= min) { min = temp; mint = v["inputTime"]; }
                                            sum = sum + temp;
                                            snum=snum+1;
                                        }
                                    });
                                    if (snum>0)
                                    sresult = "其中" + strs[i] + "，最大数为：" + max + ",发生日期是：" + maxt + "，最小数为：" + min + "，发生日期是：" + mint + "，平均数为：" + sum / snum+"。";

                                }
                                else {
                                    if (data.rows.length > 0) min = parseInt(data.rows[0]["totalCount"]);
                                    $.each(data.rows, function (k, v) {
                                        if (v["hname"] == strs[i]) {
                                            temp = parseInt(v["totalCount"]);
                                            if (temp > max) { max = temp; maxt = v["inputTime"]; }
                                            if (temp < min) { min = temp; mint = v["inputTime"]; }
                                            sum = sum + temp;
                                            snum = snum + 1;
                                        }
                                    });
                                    if (snum > 0)
                                    sresult = "其中" + strs[i] + "最大数为：" + max + ",发生日期是：" + maxt + "，最小数为：" + min + "，发生日期是：" + mint + "，平均数为：" + sum / snum + "。";
                                }
                                //统计结果
                                result = result + sresult;
                            }
                            if (dtOpstart != "") dtOpstart = dtOpstart + "到";
                            if (dtOpend != "") dtOpstart = dtOpstart + dtOpend;
                            result = dtOpstart + "，" + add + "的用户" + name + "上报的数据中共中害虫" + nums + "种，分别为：" + pets + "。" + result;
                        
                            $('#yjfx').text(result);

                    }
                });
                Highcharts.setOptions({
                    lang: {
                        contextButtonTitle: "图表导出菜单",
                        decimalPoint: ".",
                        downloadJPEG: "下载JPEG图片",
                        downloadPDF: "下载PDF文件",
                        downloadPNG: "下载PNG文件",
                        downloadSVG: "下载SVG文件",
                        drillUpText: "返回 {series.name}",
                        loading: "加载中",
                        months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                        noData: "没有数据",
                        numericSymbols: ["千", "兆", "G", "T", "P", "E"],
                        printChart: "打印图表",
                        resetZoom: "恢复缩放",
                        resetZoomTitle: "恢复图表",
                        shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
                        thousandsSep: ",",
                        weekdays: ["星期一", "星期二", "星期三", "星期三", "星期四", "星期五", "星期六", "星期天"]
                    }
                });            
            
            }
            function getQueryParams(queryParams) {
                var StartTime = $("#StartTime").datebox("getValue");
                var EndTime = $("#EndTime").datebox("getValue");
                var idstr = $("#idstr").val();
                var idh = $("#idh").val();
                var otype = $("#otype").val();
                var ptype = $("#ptype").combobox("getValue");
                mpet = $("#mypets").combobox("getValue");
                queryParams.StartTime = StartTime;
                queryParams.EndTime = EndTime;
                queryParams.idstr = idstr;
                queryParams.idh = idh;
                queryParams.otype = otype;
                queryParams.mypet= mpet;
                queryParams.ptype=ptype;
                return queryParams;

            }
            //增加查询参数，重新加载表格  
            function reloadgrid() {
                var queryParams = $('#tt').datagrid('options').queryParams;
                getQueryParams(queryParams);
                $('#tt').datagrid('options').queryParams = queryParams;
                $("#tt").datagrid('reload');

            }
            var wchartInstance;
            var WChartJS = {
                init: function (chs) {
                    var s = "[";
                    $.each(chs, function () {
                        s = s + "{name:'" + this + "',data:[]},";
                    });
                    s = s.substr(0, s.length - 1);
                    s = s + "]";
                    wchartInstance = new Highcharts.Chart({
                        chart: {
                            renderTo: 'chartArea',
                            type: 'line'
                        },
                        credits: {
                            enabled: false
                        },
                        exporting: {
                            enabled: true
                        },
                        title: {
                            text: '',
                            x: -20 //center
                        },
                        xAxis: {
                            type: 'datetime',
                            labels: {
                                step: 4,
                                formatter: function () {
                                    return new Date(this.value).toLocaleDateString();
                                }
                            }
                        },
                        plotOptions: {
                            series: {
                                events: {
                                    legendItemClick: function () {
                                        var visibility = this.visible ? 'visible' : 'hidden';
                                        if (visibility == 'hidden') {
                                            for (var i = 0; i < qxchs.length; i++) {
                                                wchartInstance.series[i].hide();
                                            }                                            
                                        }
                                        return true;
                                    }
                                }
                            }
                        },
                        yAxis: {
                            title: {
                                text: '数值'
                            },
                            plotLines: [{
                                value: 0,
                                width: 1,
                                color: '#808080'
                            }]
                        },
                        tooltip: {
                            formatter: function () {
                                if (this.series.name == '风向') {
                                    var d = this.y;
                                    var res = "";
                                    if (d < 15 || d >= 345)
                                        res = "北";
                                    else if (d >= 15 && d < 45)
                                        res = "东北偏北";
                                    else if (d >= 45 && d < 75)
                                        res = "东北偏东";
                                    else if (d >= 75 && d < 105)
                                        res = "东";
                                    else if (d >= 105 && d < 135)
                                        res = "东南偏东";
                                    else if (d >= 135 && d < 165)
                                        res = "东南偏南";
                                    else if (d >= 165 && d < 195)
                                        res = "南";
                                    else if (d >= 195 && d < 225)
                                        res = "西南偏南";
                                    else if (d >= 225 && d < 255)
                                        res = "西南偏西";
                                    else if (d >= 255 && d < 285)
                                        res = "西";
                                    else if (d >= 285 && d < 315)
                                        res = "西北偏西";
                                    else if (d >= 315 && d < 345)
                                        res = "西北偏北";
                                    return '<b>' + this.series.name + '：</b>' + res + '<br/> <b>时间：</b>' + new Date(this.x).toLocaleString();
                                }
                                else
                                    return '<b>' + this.series.name + '：</b>' + this.y + '<br/> <b>时间：</b>' + new Date(this.x).toLocaleString();
                            }

                        },
                        legend: {
                            //layout: 'vertical',
                            align: 'center',
                            verticalAlign: 'top',
                            borderWidth: 0
                        },
                        series: eval(s)
                    });
                }
            };

            var CRUD = {
                init: function () {
                    if (phone == "") {
                        $.messager.alert("提示", "对不起，这个用户没有小气候数据！", "info");
                        return;
                    }
                    filterObj = "";
                    dtOpstart = $('#StartTime').datebox('getValue');
                    dtOpend = $('#EndTime').datebox('getValue');
                    var ruleArr = [];
                    if (dtOpstart != '')
                        ruleArr.push({ "field": "datetime", "op": "ge", "data": dtOpstart });
                    if (dtOpend != '')
                        ruleArr.push({ "field": "datetime", "op": "le", "data": dtOpend });
                    if (ruleArr.length > 0) {
                        filterObj = { groupOp: 'AND', rules: ruleArr };
                        $('body').data('where', filterObj);
                    }
                    jQuery.getJSON(qxurl + '/Dev/ashx/DevCon.ashx?action=getmylist&XQHID=' + phone + '&r=' + Math.floor(Math.random() * (1000 + 1)), null, function (data) {
                        mpet = $("#mypets").combobox("getText");
                   
                        var mchs = data.XQHID;
                        qxchs = mchs.split(',');
                        qxchs.deleteElementByValue("风向");
                        if (qxchs.length != 0) {
                            if (mpet != "" && mpet != "全部") {
                                if ($("#ptype").combobox('getValue') == "成虫")
                                    mchs = mchs + "," + mpet + "雌虫," + mpet + "雄虫," + mpet + "成虫";
                                else
                                    mchs = mchs + "," + mpet + "统计";
                                chs = mchs.split(',');
                                chs.deleteElementByValue("风向");
                                WChartJS.init(chs);
                                CRUD.show();
                            }
                            else {
                                $.messager.alert("提示", "对不起，请选择虫子！", "info");
                                return;
                            }
                        }
                        else {
                            $.messager.alert("提示", "对不起，小气候数据没有参数！", "info");
                        }
                    });
                },
                show: function () {
                    
                    //WChartJS.init(chs);
                    var rows = $('#tt').datagrid('getPager').data("pagination").options.pageSize;
                    jQuery.getJSON(qxurl + '/status_xqh/ashx/XQH.ashx?action=phoneavg&devID=' + phone + '&filter=' + JSON.stringify(filterObj) + '&page=1&rows=' + rows + '&r=' + Math.floor(Math.random() * (1000 + 1)), null, function (data) {
                        if (data.rows.length == 0)
                        {
                            $.messager.alert("提示", "满足此条件的气候数据不存在！", "info");
                            return;
                        }
                        var md;
                        var t1 = "",t2="",t3="";
                        if ($("#ptype").combobox('getValue')!= "成虫") {
                            var n = chs.length - 1;
                            for (var i = 0; i < n; i++) {
                                t1 = "";
                                $.each(data.rows, function (k, v) {
                                    md = v["datetime"];
                                    md = md.replace(/-/g, "/");
                                    md = Date.parse(md);
                                    t1 = "[" + md + "," + v[chs[i]] + "]," + t1;

                                });
                                t1 = "[" + t1 + "]";
                                wchartInstance.series[i].setData(eval(t1));
                            }
                            t1 = "";
                            $.each(griddata.rows, function (k, v) {
                                md = v["inputTime"];
                                md = md.replace(/-/g, "/");
                                md = Date.parse(md);
                                t1 = "[" + md + "," + v["totalCount"] + "]," + t1;

                            });
                            t1 = "[" + t1 + "]";
                            wchartInstance.series[n].setData(eval(t1));
                        }
                        else {
                            var n = chs.length - 3;
                            for (var i = 0; i < n; i++) {
                                t1 = "";
                                $.each(data.rows, function (k, v) {
                                    md = v["datetime"];
                                    md = md.replace(/-/g, "/");
                                    md = Date.parse(md);
                                    t1 = "[" + md + "," + v[chs[i]] + "]," + t1;

                                });
                                t1 = "[" + t1 + "]";
                                wchartInstance.series[i].setData(eval(t1));
                            }
                            t1 = "";
                            var fmc = "";
                            $.each(griddata.rows, function (k, v) {
                                md = v["inputTime"];
                                md = md.replace(/-/g, "/");
                                md = Date.parse(md);
                                t1 = "[" + md + "," + v["femaleNums"] + "]," + t1;
                                t2 = "[" + md + "," + v["maleNums"] + "]," + t2;
                                fmc = parseInt(v["femaleNums"]) + parseInt(v["maleNums"]);
                                t3 = "[" + md + "," + fmc + "]," + t3;

                            });
                            t1 = "[" + t1 + "]";
                            t2 = "[" + t2 + "]";
                            t3 = "[" + t3 + "]";
                            wchartInstance.series[chs.length - 3].setData(eval(t1));
                            wchartInstance.series[chs.length - 2].setData(eval(t2));
                            wchartInstance.series[chs.length - 1].setData(eval(t3));
                        }
                        for (var i = 0; i < qxchs.length; i++) {
                            if (i != 0)
                                wchartInstance.series[i].hide();
                        }

                    });
                }
            };
            function remove()
            {               
                var row = $('#tt').datagrid('getSelections');
                if (row == null || row.length == 0) {
                    $.messager.alert("提示", "请选择要删除的行！", "info");
                }
                if (row) {
                    $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                        if (r) {
                            var ids = getfids(row);
                            jQuery.getJSON('GetPets.ashx?action=del&ids=' + ids, null, function (data) {
                                if (data[0].r == "T") {
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    reloadgrid();
                                }
                                else {
                                    $.messager.alert("提示", "信息删除失败！", "info");
                                }
                            });
                        }
                    });
                    }
            }
        </script>
    <style>
        .fitem {
            float: left;
        }

            .fitem label {
                width: 30px;
                line-height: 24px;
            }
             .dl1 {
            color:green;
            font-weight:bold;
        }
        .dl2 {
            color:blue;
            font-weight:bold;
        }
        .dl3 {
            color:yellow;
            font-weight:bold;
        }
        .dl4 {
            color:red;
            font-weight:bold;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-layout" data-options="fit:true">  
            
    <div data-options="region:'north'" style="padding:5px;background:#eee;height:300px;">

    <table id="tt">
    </table>
    </div>
        <div id="chartArea" data-options="region:'center',split:true"></div>    
    <div  id="yjfx" data-options="region:'south',title: '虫情分析',tools: [{ iconCls: 'icon-phone', handler:opend}],split:true" style="height:60px;">
        虫情分析：
    </div>   
   
    
</div>  


    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <td style="padding-left: 2px">

                    <div style="padding: 2px;">
                        时间从:  
           <input id="StartTime" class="easyui-datebox" style="width: 100px" />
                            到:  
           <input id="EndTime" class="easyui-datebox" style="width: 100px" />
                         <select id="jd" class="easyui-combobox" name="jd" style="width:80px;">
                    <option value="季度">季度</option>
                                <option value="一季度">一季度</option>
                                <option value="二季度">二季度</option>
                                <option value="三季度">三季度</option>
                                <option value="四季度">四季度</option>
                    <option value="当天">当天</option>
</select>   
                         <select id="ptype" class="easyui-combobox" name="ptype" style="width:60px;">
                                <option value="所有">所有</option>   
   <option value="卵">卵</option>
                                <option value="幼虫">幼虫</option>
                                <option value="蛹">蛹</option>
                                <option value="成虫">成虫</option>
</select>
                        <input id="mypets" type="text" style="width:100px;"/>    
                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a>
                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="Export('excel', $('#tt'));">导出</a>
                             
                              <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="CRUD.init();">分析</a> 
                        <a href="#" onclick="remove();return false;" id="a_del" class="easyui-linkbutton" iconcls="icon-cancel">删除</a>          
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <form id="fm" method="post"></form>
    <div id="dlg" class="easyui-dialog" style="width: 400px; height: 400px; padding: 5px"
        data-options="closed:true,buttons:'#dlg-buttons',shadow:false"> 
        <table id="suser"></table>
    </div>
    <div id="dlg-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="sendmsg()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
    </div>
</asp:Content>

